package com.tianyi.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.FilterRegistration;
import java.util.logging.Filter;

/**
 * @Author tianyi
 * @Description // todo
 * @Date 2022 - 10 - 30
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    RepeatUrlDataInterceptor repeatUrlDataInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(repeatUrlDataInterceptor)
                .addPathPatterns("/**");
    }
    @Bean
    public FilterRegistrationBean setRepeatUrlMethodFilter(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean(new RepeatUrlMethodFilter());
        registrationBean.setName("interceptor filter body params");
        registrationBean.addUrlPatterns("*");
        registrationBean.setOrder(1);
        return registrationBean;
    }

}
